package com.lyz.dataStructure.LeetCode100;



import scala.beans.ScalaBeanInfo;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 类描述：
 *
 * @ClassName 两数之和1
 * @Description:
 * @Author: liyaozhou
 * @Date: 2021/8/8 19:45
 */
public class 两数之和1 {
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        int i = sc.nextInt();



    }

    public static int[] sum(int[] arr,int target){
        //[2,6,7,11,12]   9
        //1、先创建一个hashMap，
        Map<Integer,Integer> map = new HashMap<>();

        for(int i = 0; i < arr.length ; i++){
            //2 遍历数组，如果创建的集合中包含 target - a = b,就直接从hashmap中取出对应值的下标
            if (map.containsKey(target - arr[i])){

                return  new int[] {map.get(target - arr[i]),i};
            }
            //3 key存放数组的值，value存放数组的下标
            map.put(arr[i],i);
        }
        return null;
    }
 }
